package maze;

/**
 *
 * @author Dennis Nijssen
 */
public enum Direction {
    NORTH(0, -1), SOUTH(0, 1), EAST(1, 0), WEST(-1, 0);
    
    private final int dx;
    private final int dy;
    
    private Direction(int dx, int dy) {
        this.dx = dx;
        this.dy = dy;
    }
    
    public static Direction getDirection(int currentX, int currentY, int newX, int newY) {
        int dx = newX - currentX;
        int dy = newY - currentY;
        
        if(dx == 0) {
            if(dy == -1) {
                return NORTH;
            } else {
                return SOUTH;
            }
        } else if(dx == 1) {
            return EAST;
        }
        
        return WEST;
        
    }
    
    public int getDx() {
        return this.dx;
    }
    
    public int getDy() {
        return this.dy;
    }
}